using dnAnalytics.Math;
using NUnit.Framework;

namespace dnAnalytics.Tests.Math
{
    [TestFixture]
    public class ComplexMath_AcosTest
    {
        [Test]
        public void Acos()
        {
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, 1.19209289550780998537e-7)), new Complex(1.57079632679489661923, -1.19209289550780716193e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, -1.19209289550780998537e-7)), new Complex(1.57079632679489661923, 1.19209289550780716193e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, 5.0e-1)), new Complex(1.57079632679489661923, -4.81211825059603447498e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, -5.0e-1)), new Complex(1.57079632679489661923, 4.81211825059603447498e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, 1.0)), new Complex(1.57079632679489661923, -8.81373587019543025233e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, -1.0)), new Complex(1.57079632679489661923, 8.81373587019543025233e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, 2.0)), new Complex(1.57079632679489661923, -1.44363547517881034249), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, -2.0)), new Complex(1.57079632679489661923, 1.44363547517881034249), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, 8.388608e6)), new Complex(1.57079632679489661923, -1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(0.0, -8.388608e6)), new Complex(1.57079632679489661923, 1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 0.0)), new Complex(1.57079620758560706845, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 0.0)), new Complex(1.57079644600418617001, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(1.57079620758560706845, -1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(1.57079620758560706845, 1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 1.19209289550780998537e-7)), new Complex(1.57079644600418617001, -1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, -1.19209289550780998537e-7)), new Complex(1.57079644600418617001, 1.19209289550781563226e-7), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 5.0e-1)), new Complex(1.57079622017086662523, -4.81211825059605989613e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, -5.0e-1)), new Complex(1.57079622017086662523, 4.81211825059605989613e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 5.0e-1)), new Complex(1.57079643341892661323, -4.81211825059605989613e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, -5.0e-1)), new Complex(1.57079643341892661323, 4.81211825059605989613e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 1.0)), new Complex(1.57079624250119959744, -8.81373587019545537381e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, -1.0)), new Complex(1.57079624250119959744, 8.81373587019545537381e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 1.0)), new Complex(1.57079641108859364102, -8.81373587019545537381e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, -1.0)), new Complex(1.57079641108859364102, 8.81373587019545537381e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 2.0)), new Complex(1.57079627348288162223, -1.44363547517881161355), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, -2.0)), new Complex(1.57079627348288162223, 1.44363547517881161355), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 2.0)), new Complex(1.57079638010691161623, -1.44363547517881161355), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, -2.0)), new Complex(1.57079638010691161623, 1.44363547517881161355), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, 8.388608e6)), new Complex(1.57079632679488240838, -1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.19209289550780998537e-7, -8.388608e6)), new Complex(1.57079632679488240838, 1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, 8.388608e6)), new Complex(1.57079632679491083009, -1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.19209289550780998537e-7, -8.388608e6)), new Complex(1.57079632679491083009, 1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 0.0)), new Complex(1.04719755119659774615, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 0.0)), new Complex(2.09439510239319549231, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 1.19209289550780998537e-7)), new Complex(1.04719755119660321591, -1.37651030824094033271e-7), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, -1.19209289550780998537e-7)), new Complex(1.04719755119660321591, 1.37651030824094033271e-7), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 1.19209289550780998537e-7)), new Complex(2.09439510239319002255, -1.37651030824094033271e-7), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, -1.19209289550780998537e-7)), new Complex(2.09439510239319002255, 1.37651030824094033271e-7), 8);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 5.0e-1)), new Complex(1.11851787964370593717, -5.30637530952517826017e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, -5.0e-1)), new Complex(1.11851787964370593717, 5.30637530952517826017e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 5.0e-1)), new Complex(2.02307477394608730129, -5.30637530952517826017e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, -5.0e-1)), new Complex(2.02307477394608730129, 5.30637530952517826017e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 1.0)), new Complex(1.2213572639376833256, -9.2613303135018242455e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, -1.0)), new Complex(1.2213572639376833256, 9.2613303135018242455e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 1.0)), new Complex(1.92023538965210991286, -9.2613303135018242455e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, -1.0)), new Complex(1.92023538965210991286, 9.2613303135018242455e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 2.0)), new Complex(1.34977769117201276033, -1.46571535194729052178), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, -2.0)), new Complex(1.34977769117201276033, 1.46571535194729052178), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 2.0)), new Complex(1.79181496241778047813, -1.46571535194729052178), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, -2.0)), new Complex(1.79181496241778047813, 1.46571535194729052178), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, 8.388608e6)), new Complex(1.57079626719025184384, -1.66355323334386927551e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(5.0e-1, -8.388608e6)), new Complex(1.57079626719025184384, 1.66355323334386927551e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, 8.388608e6)), new Complex(1.57079638639954139462, -1.66355323334386927551e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-5.0e-1, -8.388608e6)), new Complex(1.57079638639954139462, 1.66355323334386927551e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 0.0)), new Complex(0.0, 0.0), 9);
            //            TestHelper.TestLogRelativeError(ComplexMath.Acos(new Complex(-1.0, 0.0)), new Complex(3.14159265358979323846, 0.0), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 1.19209289550780998537e-7)), new Complex(3.45266979571324139834e-4, -3.45266986431162764654e-4), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, -1.19209289550780998537e-7)), new Complex(3.45266979571324139834e-4, 3.45266986431162764654e-4), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, 1.19209289550780998537e-7)), new Complex(3.14124738661022191432, -3.45266986431162764654e-4), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, -1.19209289550780998537e-7)), new Complex(3.14124738661022191432, 3.45266986431162764654e-4), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 5.0e-1)), new Complex(6.74888845586006380165e-1, -7.32857675973645260889e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, -5.0e-1)), new Complex(6.74888845586006380165e-1, 7.32857675973645260889e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, 5.0e-1)), new Complex(2.4667038080037868583, -7.32857675973645260889e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, -5.0e-1)), new Complex(2.4667038080037868583, 7.32857675973645260889e-1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 1.0)), new Complex(9.04556894302381364127e-1, -1.06127506190503565203), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, -1.0)), new Complex(9.04556894302381364127e-1, 1.06127506190503565203), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, 1.0)), new Complex(2.23703575928741187434, -1.06127506190503565203), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, -1.0)), new Complex(2.23703575928741187434, 1.06127506190503565203), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 2.0)), new Complex(1.14371774040242049375, -1.52857091948099816127), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, -2.0)), new Complex(1.14371774040242049375, 1.52857091948099816127), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, 2.0)), new Complex(1.99787491318737274471, -1.52857091948099816127), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, -2.0)), new Complex(1.99787491318737274471, 1.52857091948099816127), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, 8.388608e6)), new Complex(1.57079620758560706845, -1.66355323334386980842e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(1.0, -8.388608e6)), new Complex(1.57079620758560706845, 1.66355323334386980842e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, 8.388608e6)), new Complex(1.57079644600418617001, -1.66355323334386980842e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-1.0, -8.388608e6)), new Complex(1.57079644600418617001, 1.66355323334386980842e1), 9);
            //            TestHelper.TestLogRelativeError(ComplexMath.Acos(new Complex(-2.0, 0.0)), new Complex(3.14159265358979323846, -1.31695789692481670863), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, 1.19209289550780998537e-7)), new Complex(6.88255154120472883216e-8, -1.31695789692481944351), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, -1.19209289550780998537e-7)), new Complex(6.88255154120472883216e-8, 1.31695789692481944351), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, 1.19209289550780998537e-7)), new Complex(3.14159258476427782642, -1.31695789692481944351), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, -1.19209289550780998537e-7)), new Complex(3.14159258476427782642, 1.31695789692481944351), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, 5.0e-1)), new Complex(2.77754256557713960178e-1, -1.36180090085784578821), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, -5.0e-1)), new Complex(2.77754256557713960178e-1, 1.36180090085784578821), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, 5.0e-1)), new Complex(2.86383839703207927829, -1.36180090085784578821), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, -5.0e-1)), new Complex(2.86383839703207927829, 1.36180090085784578821), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, 1.0)), new Complex(5.07356303217144563042e-1, -1.46935174436818527326), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, -1.0)), new Complex(5.07356303217144563042e-1, 1.46935174436818527326), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, 1.0)), new Complex(2.63423635037264867542, -1.46935174436818527326), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, -1.0)), new Complex(2.63423635037264867542, 1.46935174436818527326), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, 2.0)), new Complex(8.16547182096850578524e-1, -1.73432452148796644796), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, -2.0)), new Complex(8.16547182096850578524e-1, 1.73432452148796644796), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, 2.0)), new Complex(2.32504547149294265994, -1.73432452148796644796), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, -2.0)), new Complex(2.32504547149294265994, 1.73432452148796644796), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, 8.388608e6)), new Complex(1.57079608837631751768, -1.66355323334387194004e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(2.0, -8.388608e6)), new Complex(1.57079608837631751768, 1.66355323334387194004e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, 8.388608e6)), new Complex(1.57079656521347572079, -1.66355323334387194004e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-2.0, -8.388608e6)), new Complex(1.57079656521347572079, 1.66355323334387194004e1), 9);
            //            TestHelper.TestLogRelativeError(ComplexMath.Acos(new Complex(-8.388608e6, 0.0)), new Complex(3.14159265358979323846, -1.66355323334386838733e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, 1.19209289550780998537e-7)), new Complex(1.42108547152020747149e-14, -1.66355323334386838733e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, 1.19209289550780998537e-7)), new Complex(3.14159265358977902761, -1.66355323334386838733e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, -1.19209289550780998537e-7)), new Complex(3.14159265358977902761, 1.66355323334386838733e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, 5.0e-1)), new Complex(5.96046447753909779304e-8, -1.66355323334386856497e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, -5.0e-1)), new Complex(5.96046447753909779304e-8, 1.66355323334386856497e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, 5.0e-1)), new Complex(3.14159259398514846307, -1.66355323334386856497e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, -5.0e-1)), new Complex(3.14159259398514846307, 1.66355323334386856497e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, 1.0)), new Complex(1.19209289550781532344e-7, -1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, -1.0)), new Complex(1.19209289550781532344e-7, 1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, 1.0)), new Complex(3.14159253438050368768, -1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, -1.0)), new Complex(3.14159253438050368768, 1.66355323334386909787e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, 2.0)), new Complex(2.38418579101559676557e-7, -1.6635532333438712295e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, -2.0)), new Complex(2.38418579101559676557e-7, 1.6635532333438712295e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, 2.0)), new Complex(3.1415924151712141369, -1.6635532333438712295e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, -2.0)), new Complex(3.1415924151712141369, 1.6635532333438712295e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, 8.388608e6)), new Complex(7.85398163397450085973e-1, -1.69821059237186600807e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(8.388608e6, -8.388608e6)), new Complex(7.85398163397450085973e-1, 1.69821059237186600807e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, 8.388608e6)), new Complex(2.35619449019234315249, -1.69821059237186600807e1), 9);
            TestHelper.TestSignificantDigits(ComplexMath.Acos(new Complex(-8.388608e6, -8.388608e6)), new Complex(2.35619449019234315249, 1.69821059237186600807e1), 9);
        }
    }
}
